from django.contrib.auth.models import User
from django.db import models

class Task(models.Model):
    title = models.CharField(max_length=255, help_text='任务标题', verbose_name='任务标题')
    content = models.TextField(help_text='任务内容', verbose_name='任务内容')
    is_online = models.BooleanField(default=True, help_text='是否上线', verbose_name='是否上线')

    created_time = models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name="创建时间")
    last_modified = models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name="修改时间")

    creator = models.ForeignKey(related_name='creator_id', to=User, to_field="id", on_delete=models.CASCADE, verbose_name='发布人员')
    actor = models.ForeignKey(related_name='actor_id', to=User, to_field="id", on_delete=models.CASCADE, verbose_name='业务人员')

    status_choices = (
        (0, '未完成'),
        (1, '已完成'),
    )

    status = models.SmallIntegerField(default=0, choices=status_choices, verbose_name='任务状态')

    class Meta:
        ordering = ('-created_time',)
        verbose_name = '任务发布'
        verbose_name_plural='任务发布'

    def __str__(self):
        return self.title